<%@ include file="database_ini.jsp"%>


<%  
	
	//String dropid = request.getParameter("DROPID");
	
	//response.sendRedirect("index.jsp");
	
	String Serailkey[] = request.getParameterValues("Serailkey");
	
	
	String type = request.getParameter("type");
	
	if (Serailkey != null) {
		
		/*********debug*/
		System.out.println("Serailkey: " + Serailkey[0]);
		System.out.println("type: " + type);
		/**********/
		
		String CCParameterName = request.getParameter("CCParameterName");
		String StorerkeyFrom = request.getParameter("StorerkeyFrom");
		String StorerkeyTo = request.getParameter("StorerkeyTo");
		String SkuFrom = request.getParameter("SkuFrom");
		String SkuTo = request.getParameter("SkuTo");
		String ClassFrom = request.getParameter("ClassFrom");
		String ClassTo = request.getParameter("ClassTo");
		String ZoneFrom = request.getParameter("ZoneFrom");
		String ZoneTo = request.getParameter("ZoneTo");
		String LocFrom = request.getParameter("LocFrom");
		String LocTo = request.getParameter("LocTo");
		int XCOORDFROM = Integer.parseInt(request.getParameter("XCOORDFROM"));
		int XCOORDTO = Integer.parseInt(request.getParameter("XCOORDTO"));
		int YCOORDFROM = Integer.parseInt(request.getParameter("YCOORDFROM"));
		int YCOORDTO = Integer.parseInt(request.getParameter("YCOORDTO"));
		int ZCOORDFROM = Integer.parseInt(request.getParameter("ZCOORDFROM"));
		int ZCOORDTO = Integer.parseInt(request.getParameter("ZCOORDTO"));
		String DisplaySystemCount = request.getParameter("DisplaySystemCount");
		if(DisplaySystemCount==null){
			DisplaySystemCount = "0";
		}
		
		/**********/
		
		System.out.println("type: " + type);
		System.out.println("CCParameterName: " + CCParameterName);
		System.out.println("StorerkeyFrom: " + StorerkeyFrom);
		System.out.println("StorerkeyTo: " + StorerkeyTo);
		System.out.println("SkuFrom: " + SkuFrom);
		System.out.println("SkuTo: " + SkuTo);
		System.out.println("ClassFrom: " + ClassFrom);
		System.out.println("ClassTo: " + ClassTo);
		System.out.println("ZoneFrom: " + ZoneFrom);
		System.out.println("ZoneTo: " + ZoneTo);
		System.out.println("LocFrom: " + LocFrom);
		System.out.println("LocTo: " + LocTo);
		System.out.println("XCOORDFROM: " + XCOORDFROM);
		System.out.println("XCOORDTO: " + XCOORDTO);
		System.out.println("YCOORDFROM: " + YCOORDFROM);
		System.out.println("YCOORDTO: " + YCOORDTO);
		System.out.println("ZCOORDFROM: " + ZCOORDFROM);
		System.out.println("ZCOORDTO: " + ZCOORDTO);
		System.out.println("DisplaySystemCount: " + DisplaySystemCount);
		/**********/
		
		Statement st = null;
		int CCKEY = 0;
		int CCRptLine = 20;
		String stsql = "";
		String CCDROPID="";
		
		stsql = "select CODE from CODELKUP WHERE LISTNAME = 'CCRptLine' ";
		st = conn.createStatement();
		ResultSet CCRptLine_rs = st.executeQuery(stsql);
		
		/**********/
		System.out.println("stsql: " + stsql);
		/**********/
		
		if(CCRptLine_rs.next()){
			CCRptLine = Integer.parseInt(CCRptLine_rs.getString("CODE"));
		}
		
		/**********/
		System.out.println("CCRptLine: " + CCRptLine);
		/**********/
		
		
		
				
		
		stsql = "select KEYCOUNT from NCOUNTER where KEYNAME = 'CCKEY' ";
		st = conn.createStatement();
		ResultSet strs = st.executeQuery(stsql);
		
		
		
		if(strs.next()){
			
			CCKEY = strs.getInt("KEYCOUNT");
			CCKEY = CCKEY + 1;
			/*********debug*/
			System.out.println("CCKEY: " + CCKEY);
			/**********/
			stsql = "update NCOUNTER set KEYCOUNT = " + CCKEY + " where KEYNAME = 'CCKEY' ";
			st = conn.createStatement();
			st.executeUpdate(stsql);
			
			
			String sql ="";
			
			if(type.equalsIgnoreCase("EMPTY")){
			
				stsql = " insert into CCHDR (CCKEY, Status, RELEASEDATE, CCParameterName, ZoneFrom, ZoneTo, LocFrom, LocTo, XCOORDFROM, XCOORDTO, YCOORDFROM, YCOORDTO, ZCOORDFROM, ZCOORDTO, DisplaySystemCount) values( '" 
				+ String.format("%010d", CCKEY) + "', '0', GETDATE(), '" + CCParameterName + "', '"  + ZoneFrom + "', '" + ZoneTo + "', '" 
				//+ CCKEY + "', '0', SYSDATE, '" + CCParameterName + "', '"  + ZoneFrom + "', '" + ZoneTo + "', '" 
				+ LocFrom + "', '" + LocTo + "', '" + XCOORDFROM + "', '" + XCOORDTO + "', '" + YCOORDFROM + "', '" + YCOORDTO + "', '" 
				+ ZCOORDFROM + "', '" + ZCOORDTO + "', '" + DisplaySystemCount + "')";
				/*********debug*/
				System.out.println("stsql: " + stsql);
				/**********/
				
				st = conn.createStatement();
				st.executeUpdate(stsql);
				
				sql = "select LOTXLOCXID.Lot, LOTXLOCXID.Loc, LOTXLOCXID.ID, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTXLOCXID.QTY, LOTATTRIBUTE.LOTTABLE05, SKU.CLASS, SKU.Descr, SKU.GeneralSku AS UPCCode, LOC.XCOORD, LOC.YCOORD, LOC.ZCOORD, PUTAWAYZONE.PUTAWAYZONE AS ZONE from LOTXLOCXID, SKU, LOC,LOTATTRIBUTE, PUTAWAYZONE "
				+ "WHERE LOTXLOCXID.Storerkey = SKU.Storerkey AND LOTXLOCXID.Sku = SKU.Sku AND LOTXLOCXID.Loc = LOC.Loc AND LOTXLOCXID.Lot = LOTATTRIBUTE.Lot AND LOTXLOCXID.Storerkey = LOTATTRIBUTE.Storerkey AND LOTXLOCXID.Sku = LOTATTRIBUTE.Sku AND LOC.PUTAWAYZONE = PUTAWAYZONE.PUTAWAYZONE "
				+ "and PUTAWAYZONE.PUTAWAYZONE between ? and ?  and LOTXLOCXID.Loc between ? and ? "
				// "and LOTXLOCXID.Storerkey between ? and ?  and LOTXLOCXID.Sku between ? and ?  and SKU.CLASS between ? and ? and LOTXLOCXID.Loc between ? and ?  "
				+ "and LOC.XCOORD between ? and ?  and LOC.YCOORD between ? and ?  and LOC.ZCOORD between ? and ? "
				+ "and LOTXLOCXID.QTY = 0 "
				+ "order by PUTAWAYZONE.PUTAWAYZONE, LOC.XCOORD, LOC.ZCOORD, LOTXLOCXID.Loc, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTATTRIBUTE.LOTTABLE05";
				
				pstmt = conn.prepareStatement(sql);
				pstmt.setString(1, ZoneFrom);
				pstmt.setString(2, ZoneTo);
				pstmt.setString(3, LocFrom);
				pstmt.setString(4, LocTo);
				pstmt.setInt(5, XCOORDFROM);
				pstmt.setInt(6, XCOORDTO);
				pstmt.setInt(7, YCOORDFROM);
				pstmt.setInt(8, YCOORDTO);
				pstmt.setInt(9, ZCOORDFROM);
				pstmt.setInt(10, ZCOORDTO);

			}
			else {
			
				stsql = " insert into CCHDR (CCKEY, Status, RELEASEDATE, CCParameterName, StorerkeyFrom, StorerkeyTo, SkuFrom, SkuTo, ClassFrom, ClassTo, ZoneFrom, ZoneTo, LocFrom, LocTo, XCOORDFROM, XCOORDTO, YCOORDFROM, YCOORDTO, ZCOORDFROM, ZCOORDTO, DisplaySystemCount) values( '" 
				+ String.format("%010d", CCKEY) + "', '0', GETDATE(), '" + CCParameterName + "', '" + StorerkeyFrom + "', '" + StorerkeyTo + "', '"
				//+ CCKEY + "', '0', SYSDATE, '" + CCParameterName + "', '" + StorerkeyFrom + "', '" + StorerkeyTo + "', '" 
				+ SkuFrom + "', '" + SkuTo + "', '" + ClassFrom + "', '" + ClassTo + "', '" + ZoneFrom + "', '" + ZoneTo + "', '" 
				+ LocFrom + "', '" + LocTo + "', '" + XCOORDFROM + "', '" + XCOORDTO + "', '" + YCOORDFROM + "', '" + YCOORDTO + "', '" 
				+ ZCOORDFROM + "', '" + ZCOORDTO + "', '" + DisplaySystemCount + "')";
				/*********debug*/
				System.out.println("stsql: " + stsql);
				/**********/
				
				st = conn.createStatement();
				st.executeUpdate(stsql);
				
				if(type.equalsIgnoreCase("ITRN")){
					sql = "select LOTXLOCXID.Lot, LOTXLOCXID.Loc, LOTXLOCXID.ID, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTXLOCXID.QTY, LOTATTRIBUTE.LOTTABLE05, SKU.CLASS, SKU.Descr, SKU.GeneralSku AS UPCCode, LOC.XCOORD, LOC.YCOORD, LOC.ZCOORD, PUTAWAYZONE.PUTAWAYZONE AS ZONE from LOTXLOCXID, SKU, LOC, LOTATTRIBUTE, PUTAWAYZONE "
					+ "WHERE LOTXLOCXID.Storerkey = SKU.Storerkey AND LOTXLOCXID.Sku = SKU.Sku AND LOTXLOCXID.Loc = LOC.Loc AND LOTXLOCXID.Lot = LOTATTRIBUTE.Lot AND LOTXLOCXID.Storerkey = LOTATTRIBUTE.Storerkey AND LOTXLOCXID.Sku = LOTATTRIBUTE.Sku AND LOC.PUTAWAYZONE = PUTAWAYZONE.PUTAWAYZONE "
					+ "and LOTXLOCXID.Storerkey between ? and ?  and LOTXLOCXID.Sku between ? and ?  and SKU.CLASS between ? and ? "
					+ "and PUTAWAYZONE.PUTAWAYZONE between ? and ?  and LOTXLOCXID.Loc between ? and ? "
					//+ "and LOTXLOCXID.Storerkey between ? and ?  and LOTXLOCXID.Sku between ? and ?  and SKU.CLASS between ? and ? and LOTXLOCXID.Loc between ? and ?  "
					+ "and LOC.XCOORD between ? and ?  and LOC.YCOORD between ? and ?  and LOC.ZCOORD between ? and ? "
					//+ "and (LOTXLOCXID.Loc in (select TOLoc from ITRN where SYSDATE - ITRN.ADDDATE < 1)) or (LOTXLOCXID.Loc in (select FROMLoc from ITRN where SYSDATE - ITRN.ADDDATE < 1)) "
					+ "and ((LOTXLOCXID.Loc in (select TOLoc from ITRN where DATEDIFF(day, ITRN.ADDDATE, GETDATE()) = 1)) or (LOTXLOCXID.Loc in (select FROMLoc from ITRN where DATEDIFF(day, ITRN.ADDDATE, GETDATE()) = 1) )) "
					+ "order by PUTAWAYZONE.PUTAWAYZONE, LOC.XCOORD, LOC.ZCOORD, LOTXLOCXID.Loc, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTATTRIBUTE.LOTTABLE05";	
				}
				else{
					sql = "select LOTXLOCXID.Lot, LOTXLOCXID.Loc, LOTXLOCXID.ID, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTXLOCXID.QTY, LOTATTRIBUTE.LOTTABLE05, SKU.CLASS, SKU.Descr, SKU.GeneralSku AS UPCCode, LOC.XCOORD, LOC.YCOORD, LOC.ZCOORD, PUTAWAYZONE.PUTAWAYZONE AS ZONE from LOTXLOCXID, SKU, LOC,LOTATTRIBUTE, PUTAWAYZONE "
					+ "WHERE LOTXLOCXID.Storerkey = SKU.Storerkey AND LOTXLOCXID.Sku = SKU.Sku AND LOTXLOCXID.Loc = LOC.Loc AND LOTXLOCXID.Lot = LOTATTRIBUTE.Lot AND LOTXLOCXID.Storerkey = LOTATTRIBUTE.Storerkey AND LOTXLOCXID.Sku = LOTATTRIBUTE.Sku AND LOC.PUTAWAYZONE = PUTAWAYZONE.PUTAWAYZONE "
					+ "and LOTXLOCXID.Storerkey between ? and ?  and LOTXLOCXID.Sku between ? and ?  and SKU.CLASS between ? and ? "
					+ "and PUTAWAYZONE.PUTAWAYZONE between ? and ?  and LOTXLOCXID.Loc between ? and ? "
					// "and LOTXLOCXID.Storerkey between ? and ?  and LOTXLOCXID.Sku between ? and ?  and SKU.CLASS between ? and ? and LOTXLOCXID.Loc between ? and ?  "
					+ "and LOC.XCOORD between ? and ?  and LOC.YCOORD between ? and ?  and LOC.ZCOORD between ? and ? "
					+ "order by PUTAWAYZONE.PUTAWAYZONE, LOC.XCOORD, LOC.ZCOORD, LOTXLOCXID.Loc, LOTXLOCXID.Storerkey, LOTXLOCXID.Sku, LOTATTRIBUTE.LOTTABLE05 ";
				}
				
				pstmt = conn.prepareStatement(sql);
				pstmt.setString(1, StorerkeyFrom);
				pstmt.setString(2, StorerkeyTo );
				pstmt.setString(3, SkuFrom);
				pstmt.setString(4, SkuTo);
				pstmt.setString(5, ClassFrom);
				pstmt.setString(6, ClassTo);
				pstmt.setString(7, ZoneFrom);
				pstmt.setString(8, ZoneTo);
				pstmt.setString(9, LocFrom);
				pstmt.setString(10, LocTo);
				pstmt.setInt(11, XCOORDFROM);
				pstmt.setInt(12, XCOORDTO);
				pstmt.setInt(13, YCOORDFROM);
				pstmt.setInt(14, YCOORDTO);
				pstmt.setInt(15, ZCOORDFROM);
				pstmt.setInt(16, ZCOORDTO);
			
			}
			/*********debug*/
			System.out.println("sql: " + sql);
			/**********/
	
			ResultSet rs = pstmt.executeQuery();
			
			/*********debug*/
			System.out.println("result set started");
			/**********/
			
			int PageNumber = 0;
			int TaskNumber = 0;
			
			String Lot_Pre = "";
			String Storerkey_Pre = "";
			String Sku_Pre = "";
			String ID_Pre = "";
			int QTY_Pre = 0;
			String LOTTABLE05_Pre = "";
			String CLASS_Pre = "";
			String ZONE_Pre = "";
			String Loc_Pre = "";
			int XCOORD_Pre = 0;
			int YCOORD_Pre = 0;
			int ZCOORD_Pre = 0;
			
			
			int i=0;
			while (rs.next()) {
				
				String Lot = rs.getString("Lot");
				String Storerkey = rs.getString("Storerkey");
				String Sku = rs.getString("Sku");
				String UPCCode = rs.getString("UPCCode");
				String Descr = rs.getString("Descr");
				String ID = rs.getString("ID");
				int QTY = rs.getInt("QTY");
				String LOTTABLE05 = rs.getString("LOTTABLE05");
				String CLASS = rs.getString("CLASS");
				String ZONE = rs.getString("ZONE");
				String Loc = rs.getString("Loc");
				int XCOORD = rs.getInt("XCOORD");
				int YCOORD = rs.getInt("YCOORD");
				int ZCOORD = rs.getInt("ZCOORD");
				
				int QTY_pre=0;
				
				
				/*********debug*/
				System.out.println("***************Round " + i);
				System.out.println("Lot: " + Lot);
				System.out.println("Storerkey: " + Storerkey);
				System.out.println("Sku: " + Sku);
				System.out.println("ID: " + ID);
				System.out.println("QTY: " + QTY);
				System.out.println("LOTTABLE05: " + LOTTABLE05);
				System.out.println("CLASS: " + CLASS);
				System.out.println("ZONE: " + ZONE);
				System.out.println("Loc: " + Loc);
				System.out.println("XCOORD: " + XCOORD);
				System.out.println("YCOORD: " + YCOORD);
				System.out.println("zCOORD: " + ZCOORD);
				/**********/
				
				
				
				
				
				if(ZONE.equals(ZONE_Pre) && XCOORD == XCOORD_Pre && ZCOORD == ZCOORD_Pre && TaskNumber <= CCRptLine){//Zone, x, z, CCRptLine
				
					/*********debug*/
					System.out.println("Zone, x, z, CCRptLine" + ZONE + ZONE_Pre + XCOORD + XCOORD_Pre + ZCOORD + ZCOORD_Pre + TaskNumber + CCRptLine);
					/**********/
					
					
					if(Loc.equals(Loc_Pre) && Sku.equals(Sku_Pre) && ((LOTTABLE05 == LOTTABLE05_Pre) || ((LOTTABLE05 != null) && LOTTABLE05.equals(LOTTABLE05_Pre)))){//Loc, SKU, LOTTABLE05
						/*********debug*/
						System.out.println("Loc, SKU, LOTTABLE05");
						/**********/
						
						QTY = QTY + QTY_pre;
						/*
						stsql = " update CCDET set Qty = " +  QTY
						+ " where CCKEY = '"+ String.format("%010d", CCKEY) + "' and CCDROPID = '" + CCDROPID + "' and Seq = " + TaskNumber  + " and Sku = '" + Sku + "' and Loc = '" + Loc + "' and LOTTABLE05 ='" + LOTTABLE05 + "'";
						*/
						stsql = " update CCDET set Qty = " +  QTY
						+ " where CCKEY = '"+ String.format("%010d", CCKEY) + "' and CCDROPID = '" + CCDROPID + "' and Seq = " + TaskNumber  + " and Sku = '" + Sku + "' and Loc = '" + Loc + "' and LOTTABLE05 = ?";
						/*********debug*/
						System.out.println("stsql: " + stsql);
						/**********/
						/*st.close();
						st = conn.createStatement();
						st.executeUpdate(stsql);
						*/
						PreparedStatement pstmt2 = null;
						pstmt2 = conn.prepareStatement(stsql);
						pstmt2.setString(1, LOTTABLE05);
						pstmt2.executeUpdate();
						
						
						QTY_pre = QTY;
					}
					else{
						
						/*********debug*/
						System.out.println("!!Loc, SKU, LOTTABLE05");
						/**********/
						TaskNumber++;
						/*
						stsql = " insert into CCDET (CCKEY, CCDROPID, Seq, Status, Storerkey, Sku, Descr, UPCCode, Loc, Lot, ID, LOTTABLE05, DisplaySystemCount, Qty) values( '" 
						+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + TaskNumber  + ", '0', '" + Storerkey + "', '" + Sku + "', '" + Descr + "', '" + UPCCode + "', '" + Loc + "', '" + Lot + "', '" 
						+ ID + "', '" + LOTTABLE05 + "', '" + DisplaySystemCount + "', " + QTY + " )";
						
						
						st.close();
						st = conn.createStatement();
						st.executeUpdate(stsql);
						*/
						stsql = " insert into CCDET (CCKEY, CCDROPID, Seq, Status, Storerkey, Sku, Descr, UPCCode, Loc, Lot, ID, LOTTABLE05, DisplaySystemCount, Qty) values( '" 
						+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + TaskNumber  + ", '0', '" + Storerkey + "', '" + Sku + "', '" + Descr + "', '" + UPCCode + "', '" + Loc + "', '" + Lot + "', '" 
						+ ID + "', ? , '" + DisplaySystemCount + "', " + QTY + " )";
						
						/*********debug*/
						System.out.println("stsql: " + stsql);
						/**********/
						
						PreparedStatement pstmt2 = null;
						pstmt2 = conn.prepareStatement(stsql);
						pstmt2.setString(1, LOTTABLE05);
						pstmt2.executeUpdate();
						
						QTY_pre = QTY;
						
					}
				}
				else{

					if(TaskNumber != 0){
						stsql = " insert into FIRSTCCDROPID (CCKEY, CCDROPID, PageNumber, TaskNumber) values( '" 
							+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + PageNumber + ", " + TaskNumber  + ")";
						/*********debug*/
						System.out.println("stsql: " + stsql);
						/**********/
						st.close();
						st = conn.createStatement();
						st.executeUpdate(stsql);
						
					}
					/*********debug*/
					System.out.println("!!Zone, x, z, CCRptLine" );
					/**********/
					stsql = "select KEYCOUNT from NCOUNTER where KEYNAME = 'CCDROPID' ";
					Statement CCDROPID_st = conn.createStatement();
					ResultSet CCDROPID_rs = CCDROPID_st.executeQuery(stsql);
					int CCDROPID_int = 0;
					
					PageNumber++;
					TaskNumber = 1;
										
					if(CCDROPID_rs.next()){
						CCDROPID_int = CCDROPID_rs.getInt("KEYCOUNT");
						CCDROPID_int = CCDROPID_int + 1;
						stsql = "update NCOUNTER set KEYCOUNT = " + CCDROPID_int + " where KEYNAME = 'CCDROPID' ";
						CCDROPID_st = conn.createStatement();
						CCDROPID_st.executeUpdate(stsql);
					}
					CCDROPID = String.format("%010d", CCDROPID_int);
					
					
					/*
					stsql = " insert into CCDET (CCKEY, CCDROPID, Seq, Status, Storerkey, Sku, Descr, UPCCode, Loc, Lot, ID, LOTTABLE05, DisplaySystemCount, Qty) values( '" 
					+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + TaskNumber  + ", '0', '" + Storerkey + "', '" + Sku + "', '" + Descr + "', '" + UPCCode + "', '" + Loc + "', '" + Lot + "', '" 
					+ ID + "', '" + LOTTABLE05 + "', '" + DisplaySystemCount + "', " + QTY + " )";
					
					System.out.println("stsql: " + stsql);
					
					st.close();
					st = conn.createStatement();
					st.executeUpdate(stsql);
					*/
					stsql = " insert into CCDET (CCKEY, CCDROPID, Seq, Status, Storerkey, Sku, Descr, UPCCode, Loc, Lot, ID, LOTTABLE05, DisplaySystemCount, Qty) values( '" 
					+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + TaskNumber  + ", '0', '" + Storerkey + "', '" + Sku + "', '" + Descr + "', '" + UPCCode + "', '" + Loc + "', '" + Lot + "', '" 
					+ ID + "', ? , '" + DisplaySystemCount + "', " + QTY + " )";
					PreparedStatement pstmt2 = null;
					pstmt2 = conn.prepareStatement(stsql);
					pstmt2.setString(1, LOTTABLE05);
					pstmt2.executeUpdate();
					
					QTY_pre = QTY;
				}
				
				Lot_Pre = Lot;
				Storerkey_Pre = Storerkey;
				Sku_Pre = Sku;
				ID_Pre = ID;
				QTY_Pre = QTY;
				LOTTABLE05_Pre = LOTTABLE05;
				CLASS_Pre = CLASS;
				ZONE_Pre = ZONE;
				Loc_Pre = Loc;
				XCOORD_Pre = XCOORD;
				YCOORD_Pre = YCOORD;
				ZCOORD_Pre = ZCOORD;
				
			}
			
			/*********debug*/
			System.out.println("result set ended");
			/**********/

			stsql = " insert into FIRSTCCDROPID (CCKEY, CCDROPID, PageNumber, TaskNumber) values( '" 
				+ String.format("%010d", CCKEY) + "', '" + CCDROPID + "', " + PageNumber + ", " + TaskNumber  + ")";
			/*********debug*/
			System.out.println("stsql: " + stsql);
			/**********/
			st.close();
			st = conn.createStatement();
			st.executeUpdate(stsql);
			
		}// end of if 
		
	}//end of Serailkey != null
	conn.close();
	
	String status = "ok";
	String action = "pub";
	response.sendRedirect("index.jsp?status=" + status + "&action=" + action);
%>